<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Carbon\Carbon;
use App\lists;
use App\readlinks;
use App\links;
use App\targets;
use App\memories;
use DB;

class StaticController extends Controller
{
  public function index()
  {
    $dt=Carbon::now();
    $links = DB::table('links')->orderBy('family')->get();
    $lists = DB::table('lists')->orderBy('family')->where('deleted_at','=',NULL)->get();
    $lists_number = DB::table('lists')->where('deleted_at','=',NULL)->count();
    $readlinks = DB::table('readlinks')->orderBy('family')->where('deleted_at','=',NULL)->get();
    $targets_s = DB::table('targets')->where('family','短期')->where('deleted_at','=',NULL)->get();
    $targets_m = DB::table('targets')->where('family','中期')->where('deleted_at','=',NULL)->get();
    $targets_l = DB::table('targets')->where('family','长期')->where('deleted_at','=',NULL)->get();
    $memories_links=DB::table('memories')->where('deleted_at','=',NULL)->where('type','链接')->where('recall_time','<=',$dt)->get();
    $memories_else=DB::table('memories')->where('deleted_at','=',NULL)->where('type','<>','链接')->where('recall_time','<=',$dt)->get();
    $memories_number=DB::table('memories')->where('deleted_at','=',NULL)->where('recall_time','<=',$dt)->count();
    return view('show.index',compact('links','lists','lists_number','targets_s','targets_m','targets_l','readlinks','memories_links','memories_else','memories_number'));
  }
}
